AsciiBase      PROTO :DWORD

Num            dd  0
szBuff         db  20 dup(?)

;=================================================
; Converts an ascii string to a 32 bit num value.
;=================================================
;INVOKE     AsciiBase, addr szBuff
;   mov     Num, eax
AsciiBase proc uses edx esi InPut:DWORD

         xor     eax, eax
         mov     esi, InPut
         xor     ecx, ecx
         xor     edx, edx
         mov     al, [esi]
         inc     esi
      .if al == '-'
            mov edx, -1
            mov al, [esi]
            inc esi
      .endif
      .while al != 0
            sub     al, '0'          ; Convert to bcd
            lea     ecx, [ecx+ecx*4] ; ecx = ecx * 5
            lea     ecx, [eax+ecx*2] ; ecx = eax + old ecx * 10
            mov     al, [esi]
            inc     esi
      .endw

         lea     eax, [ecx+edx]     ; Move to eax
         xor     eax, edx           ; and negate
         ret

AsciiBase endp
